<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      h1 {
        color: red;
        text-align: center;
        margin: 200px 0;
      }
    </style>
  </head>
    <h1 id="h">距离毕业还剩60天20小时50分50秒</h1>
    <script>
      var content = document.getElementById("h");

      var end = new Date("2024-8-15-00:00:00");
      time();
      setInterval(time, 1000);
      function time() {
        var now = new Date();
        var seconds = (end.getTime() - now.getTime()) / 1000;
        var d = change(parseInt(seconds / 3600 / 24));
        var h = change(parseInt((seconds / 3600) % 24));
        var m = change(parseInt((seconds / 60) % 60));
        var s = change(parseInt(seconds % 60));
        content.innerHTML = `距离毕业还剩${d}天${h}小时${m}分${s}秒`;
      }
      function change(num) {
        return num < 10 ? (num = "0" + num) : num;
      }
    </script>
  </body>
</html>
